<template>
  <div id="app">
    <keep-alive :include="Object.keys(includeComponents)">
      <router-view />
    </keep-alive>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      //缓存组件
      includeComponents: {
        homeIndex: true,
        rank: true,
        mall: true,
        community: true,
        IntegralShopping: true,
        searchPage: true,
        InWork: true,
        ExChange: true,
        ExChangeIssue: true,
        ExChangeSwapRecord: true,
        communityRecommended: true,
        communityConcern: true,
        serialHistory:true,
        secretCityCollection:true,
      }
    };
  },
  watch: {
    $route(toV) {
      const token = localStorage.getItem("Token") || "";
      if (toV.name == "login" && token) {
        this.$router.push({ name: "square" });
      }
      if (toV.meta.keepAlive) {
        this.includeComponents[toV.name] = true;
      }
    }
  },
  mounted() {}
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  font-size: 16px;
}
</style>
